#include "TextDrawing.h"
#include "MyMethods.h"


TextDrawing::TextDrawing(ID3D10Device* device)
{
	md3dDevice = device;
	m_bInit = false;
}


TextDrawing::~TextDrawing()
{
}

void TextDrawing::init()
{
	D3DX10_FONT_DESC fontDesc;
	fontDesc.Height = 24;
	fontDesc.Width = 0;
	fontDesc.Weight = 0;
	fontDesc.MipLevels = 1;
	fontDesc.Italic = false;
	fontDesc.CharSet = DEFAULT_CHARSET;
	fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS;
	fontDesc.Quality = DEFAULT_QUALITY;
	fontDesc.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
	wcscpy(fontDesc.FaceName, L"Times New Roman");
	D3DX10CreateFontIndirect(md3dDevice, &fontDesc, &mFont);
	m_bInit = true;
}

void TextDrawing::Draw()
{
	if (!m_bInit)
	{
		return;
	}
	mFont->DrawText(0, MyMethods::stringToLPCWSTR(m_text), -1, &m_rect, DT_NOCLIP, m_textColor);
}

void TextDrawing::SetText(std::string text)
{
	m_text = text;
}

void TextDrawing::SetRect(RECT rect)
{
	m_rect = rect;
}

void TextDrawing::SetColor(D3DXCOLOR color)
{
	m_textColor = color;
}


